#include "stdafx.h"
#include "TextureRender2.h"
#include "texture.h"

CTextureRender2::CTextureRender2()
{
    SetUV( 0.0f, 0.0f, 1.0f, 1.0f );
    SetUV2( 0.0f, 0.0f, 1.0f, 1.0f );
    m_textureid = -1;
    m_textureid2 = -1;
    m_vdata.vertexsize = sizeof(Vertex_RHW_TEX2);
}

CTextureRender2::~CTextureRender2()
{

}

void CTextureRender2::Render()
{
    if( m_vdata.count <= 0 )
        return;
    TextureInfo *texinfo = CD3DManager::Instance().GetTextureInfo( m_textureid );
    CHECK_PTR_VOID( texinfo );
    TextureInfo *texinfo2 = CD3DManager::Instance().GetTextureInfo( m_textureid2 );
    CHECK_PTR_VOID( texinfo2 );
    IDirect3DDevice9 *pDevice = CD3DManager::Instance().GetDevice();
    pDevice->SetTexture( 0, texinfo->texture );
    pDevice->SetTexture( 1, texinfo2->texture );
    pDevice->SetFVF(Vertex_RHW_TEX2::FVF);
   // pDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, 2, ver, sizeof(Vertex_RHW_TEX2) );
    pDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, m_vdata.count/3, m_vdata.pData, sizeof(Vertex_RHW_TEX2) );
}

void CTextureRender2::SetUV2( float u1, float v1, float u2, float v2 )
{
    m_u1_2 = u1;
    m_v1_2 = v1;
    m_u2_2 = u2;
    m_v2_2 = v2;
}

void CTextureRender2::LoadTexture2( PCTSTR filename )
{
    m_textureid2 = CD3DManager::Instance().AddTexture( filename );
}

void CTextureRender2::SetTextureID2( int id )
{
    m_textureid2 = id;
}
